package com.yc.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.R_Code;
import com.yc.Result;
import com.yc.entities.BloodSugarQualityRecords;
import com.yc.entities.custom.CustomArticleTryResponseBean;
import com.yc.entities.custom.CustomQualityRecordsResponseBean;
import com.yc.mapper.BloodSugarQualityRecordsMapper;
import com.yc.service.BloodSugarQualityRecordsService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 质控检测记录表 服务实现类
 * </p>
 *
 * @author kuakha
 * @since 2021-04-20
 */
@Service
public class BloodSugarQualityRecordsServiceImpl extends ServiceImpl<BloodSugarQualityRecordsMapper, BloodSugarQualityRecords> implements BloodSugarQualityRecordsService {

    @Override
    public Result getQualityRecords(Integer deanId, Integer departmentId, String startTime, String endTime, Integer current, Integer size) {
        Page<Integer> page = new Page<>(current == null ? 0 : current, size == null ? 10 : size);
        List<CustomQualityRecordsResponseBean> allRoleInfo = this.baseMapper.getQualityRecords(page, deanId, departmentId, startTime, endTime);
        if (page.getTotal() >= 1) {
            return Result.ok().total((int) page.getTotal()).data(allRoleInfo);
        } else {
            return Result.ok().code(R_Code.R_NULL_DATA_FAIL);
        }
    }
    @Override
    public Result getQualityRecord(Integer deanId, Integer departmentId, String startTime, String endTime) {
        List<CustomQualityRecordsResponseBean> allRoleInfo = this.baseMapper.getQualityRecords(deanId, departmentId, startTime, endTime);
        if (allRoleInfo.size() >= 1) {
            return Result.ok().data(allRoleInfo);
        } else {
            return Result.ok().code(R_Code.R_NULL_DATA_FAIL);
        }
    }
}
